-- brutal_equipment
-- created by shuzy
-- 我要最凶残的装备！

return {
    doWish = function(info)
        local args = DragonWishM.query(info["id"], "args");
        local bonus = {};
        local bonus1 = args["bonus"][1];
        local bonus2 = args["bonus"][2];

        local brutalEquipment = DungeonM.getDungeonMixedField("brutal_equipment");

        if brutalEquipment == nil or brutalEquipment <= 0 then
            -- 清空所有buff、debuff、special
            local baseAttrib = InterfaceM.calcBaseAttrib(ME.user);

            -- 获取不带BUFF下的攻击魔力
            local attack = baseAttrib["attack"];
            local magic  = baseAttrib["magic"];

            -- 攻击高于魔力，送骑士套；否则送学徒套
            if attack >= magic then
                bonus = bonus1;
                DungeonM.setDungeonMixedField("brutal_equipment", 1);
            else
                bonus = bonus2;
                DungeonM.setDungeonMixedField("brutal_equipment", 2);
            end
        elseif brutalEquipment == 1 then
            bonus = bonus2;
            DungeonM.setDungeonMixedField("brutal_equipment", 3);
        else
            bonus = bonus1;
            DungeonM.setDungeonMixedField("brutal_equipment", 3);
        end

        for _, arr in pairs(bonus) do
            BonusM.doBonus(arr, "brutal_equipment_bonus");
        end

        -- 完成对话后抛出捡物品事件
        EventMgr.fire(event.PICK_UP_ITEM, {
            ["bonus"]         = bonus,
            ["pos"]           = 25,
            ["newBonus"]      = true,
            ["type"]          = GRID_TYPE_ITEM,
            ["isItemVisible"] = true,
            ["borrowGrid"]    = true,
        });

        local msg = getLocStr("get_dragon_bonus");
        doAlert(msg);
    end,
};

